<template>
  <div id="app">
    <router-view v-if="isRouterAlive" />
  </div>
</template>

<script>
import { newPorj } from '@/utils/index.js'
export default {
  provide() {
    return {
      reload: this.reload,
    }
  },
  data() {
    return {
      isRouterAlive: true,
    }
  },
  created() {
    if (this._isMobile()) {
      window.location.href = '/wap'
    }

    newPorj().then((res) => {
      if (res.num > 0) {
        this.$message({
          duration: 10000,
          message: '您有未处理的任务，请及时处理',
          type: 'success',
        })
      }
    })
    setInterval(() => {
      newPorj().then((res) => {
        if (res.num > 0) {
          this.$message({
            duration: 10000,
            message: '您有未处理的任务，请及时处理',
            type: 'success',
          })
        }
      })
    }, 300000)
  },
  mounted() {},
  methods: {
    reload() {
      this.isRouterAlive = false
      this.$nextTick(function () {
        this.isRouterAlive = true
      })
    },
    _isMobile() {
      let flag = navigator.userAgent.match(
        /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
      )
      return flag
    },
  },
}
</script>

<style lang="scss">
* {
  margin: 0;
  padding: 0;
  // font-size: 16px;
}
.el-table__header thead tr th {
  border-right: 1px solid #ccc !important;
  border-bottom: 1px solid #ccc !important;
  background: #fafafa;
  color: #666;
}
.el-table__header thead tr th:first-child {
  border-left: 1.5px solid #ccc !important;
}
.el-table__header thead tr th:last-child {
  border-right: 1.5px solid #ccc !important;
}
.el-table__row td {
  border-right: 1px solid #ccc !important;
  border-bottom: 1px solid #ccc !important;
}
.el-table__row td:first-child {
  border-left: 1.5px solid #ccc !important;
}
.el-table__row td:last-child {
  border-right: 1.5px solid #ccc !important;
  border-bottom: 1.5px solid #ccc !important;
}
button {
  outline: none;
}

.el-tag {
  margin-right: 5px;
}
</style>
